﻿#include "pch.h"
#include "CppUnitTest.h"
#include "../Project1/test.h"
#include "read.h"
#include "judge.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace UnitTest1
{
	TEST_CLASS(UnitTest1)
	{
	public:
		TEST_METHOD(TestMethod1)
		{
			Cal c;
			judge Judge;
			vector<vector<any>> output;//预想的输出
			vector<string> outputtype;//预想的输出类型
			vector<vector<any>> input = read::readf("..\\..\\test1.txt", output, outputtype);
			vector<vector<any>> result;//调用函数返回的结果
			for (int i = 0; i < input.size(); i++) {//只需要重写这一部分就可以
				vector<any> anytem;
				anytem.push_back(c.add(*input[i][0]._Cast<int>(), *input[i][1]._Cast<double>(), *input[i][2]._Cast<string>()));
				anytem.push_back(*input[i][2]._Cast<string>());
				result.push_back(anytem);
			}
			Judge.isvecequ(output, result, outputtype);
		}
		TEST_METHOD(TestMethod2)
		{
			Cal c;
			judge Judge;
			vector<vector<any>> output;
			vector<string> outputtype;
			vector<vector<any>> input = read::readf("..\\..\\test2.txt", output, outputtype);
			vector<vector<any>> result;
			for (int i = 0; i < input.size(); i++) {//只需要重写这一部分就可以
				vector<any> anytem;
				anytem.push_back(c.sub(*input[i][0]._Cast<int>(), *input[i][1]._Cast<double>(), *input[i][2]._Cast<string>(), *input[i][3]._Cast<string>(), *input[i][4]._Cast<int>()));
				//int Cal::sub(int x, double y, string z, string t, int p)
				result.push_back(anytem);
			}
			Judge.isvecequ(output, result, outputtype);
		}
		TEST_METHOD(TestMethod3)
		{
			Cal c;
			judge Judge;
			vector<vector<any>> output;
			vector<string> outputtype;
			vector<vector<any>> input = read::readf("..\\..\\test3.txt", output, outputtype);
			vector<vector<any>> result;
			for (int i = 0; i < input.size(); i++) {//只需要重写这一部分就可以
				vector<any> anytem;
				anytem.push_back(c.mul(*input[i][0]._Cast<int>(), *input[i][1]._Cast<double>(), *input[i][2]._Cast<string>(), *input[i][3]._Cast<float>()));
				result.push_back(anytem);
			}
			Judge.isvecequ(output, result, outputtype);
		}
	};
}
